import fs from 'fs';
import http from 'http';
import url from 'url';
import path from 'path';
function publicfile(req,res){
    //地址栏请求信息
    let {pathname}=url.parse(req.url)

    req.path=pathname
    //创建我们浏览器端所需请求的文件绝对路径
    let filepath=path.join(__dirname,'./public',pathname)
    console.log(pathname)
    if(pathname==='/'){
        res.end('111')
    }else{
        if(fs.existsSync(filepath)){
            res.end(fs.readFileSync(filepath,'utf-8'))
            return true
        }
    }
}
export default publicfile;
